import {
    getMaintainctrlCustomrecordBypage,
    getMaintainctrlCustomrosterCustomparams,
    postMaintainctrlCustomrecord,
    putMaintainctrlCustomrecord,
    getMaintainctrlCustomrecordOne,
    delMaintainctrlCustomrecordOne,
    postMaintainctrlCustomrecordGetsearchlog
} from '@/api/server';
import { apiService } from '@/api/apiService';

export default function useCustomerManageSetup () {
    const getCustomerList = (param) => {
        return new Promise((resolve, reject) => {
            apiService({
                api: getMaintainctrlCustomrecordBypage,
                param: param,
                success: (data) => {
                    resolve(data);
                },
                error: (err) => {
                    reject(err);
                }
            });
        });
    };

    const getCustomrosterCustomparams = (param) => {
        return new Promise((resolve, reject) => {
            apiService({
                api: getMaintainctrlCustomrosterCustomparams,
                param: param,
                success: (data) => {
                    resolve(data);
                },
                error: (err) => {
                    reject(err);
                }
            });
        });
    };

    const postCustomrecord = (param) => {
        return new Promise((resolve, reject) => {
            apiService({
                api: postMaintainctrlCustomrecord,
                param: param,
                success: (data) => {
                    resolve(data);
                },
                error: (err) => {
                    reject(err);
                }
            });
        });
    };

    const putCustomrecord = (param) => {
        return new Promise((resolve, reject) => {
            apiService({
                api: putMaintainctrlCustomrecord,
                param: param,
                success: (data) => {
                    resolve(data);
                },
                error: (err) => {
                    reject(err);
                }
            });
        });
    };

    const getCustomrecordOne = (param) => {
        return new Promise((resolve, reject) => {
            apiService({
                api: getMaintainctrlCustomrecordOne,
                param: param,
                success: (data) => {
                    resolve(data);
                },
                error: (err) => {
                    reject(err);
                }
            });
        });
    };

    const delCustomrecordOne = (param) => {
        return new Promise((resolve, reject) => {
            apiService({
                api: delMaintainctrlCustomrecordOne,
                param: param,
                success: (data) => {
                    resolve(data);
                },
                error: (err) => {
                    reject(err);
                }
            });
        });
    };

    const getCustomrecordSearchlog = (param) => {
        return new Promise((resolve, reject) => {
            apiService({
                api: postMaintainctrlCustomrecordGetsearchlog,
                param: param,
                success: (data) => {
                    resolve(data);
                },
                error: (err) => {
                    reject(err);
                }
            });
        });
    };

    return {
        getCustomerList,
        getCustomrosterCustomparams,
        postCustomrecord,
        putCustomrecord,
        getCustomrecordOne,
        delCustomrecordOne,
        getCustomrecordSearchlog
    };
}
